package com.pan.common.util;

import com.pan.seed.Node;

/**
 * @author by panstark
 * @description
 * @notice
 * @date 2020/12/31
 */
public class DoubleNodeUtil {


    public static Node getLenghtNodeInteger(int length){

        Node node = new Node(0);

        addDoubleNode(node,0,length);

        return node;
    }

    private static void addDoubleNode(Node node, int i, int length) {
        i++;
        if(i==length){
            return;
        }
        Node next = new Node(i);
        node.setNext(next);
        next.setPre(node);
        addDoubleNode(next,i,length);
    }

    public static void main(String[] args) {

        Node node = getLenghtNodeInteger(5);
        while(node.getNext()!=null){
            node = node.getNext();
            System.out.println("当前node值为："+node.getT()+",前一个node值为："+node.getPre().getT());
        }
    }
}
